package net.ojbk.sso.center.web.interceptors;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created with IntelliJ IDEA.
 * User: twobox
 * Date: 2019/3/31
 * Time: 13:29
 * Description: No Description
 */
public class FastInterceptor implements HandlerInterceptor {
    private static Logger logger = Logger.getLogger(FastInterceptor.class);
    // Total visits 总访问量
    private int totalVisits = 0;
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        totalVisits += 1;
        logger.debug("新访问！当前后台访问次数：" + totalVisits);
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
}
